package com.innovation.sys.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.innovation.sys.common.vo.ResultMap;
import com.innovation.sys.service.LogAdminService;

@Controller
@RequestMapping("/api/admin/sys/log")
public class LogAdminController {

	private static Logger logger = LoggerFactory.getLogger(LogAdminController.class);

	@Resource
	private LogAdminService logService;

	//@RequiresPermissions("findAllLog")
	@RequestMapping(value = "/logList", method = RequestMethod.GET)
	@ResponseBody
	public ResultMap<List<Map<String, Object>>> listOfLog(HttpServletRequest request,
			@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) {
		logger.info("查询日志列表业务开始===>");
		Map map = new HashMap();
		map.put("logUser", request.getParameter("logUser"));
		map.put("createTime", request.getParameter("createTime"));
		// pageNum当前页，pageSize代表每页多少条记录
		PageHelper.startPage(pageNum, pageSize);
		// 使用PageInfo包装查询结果，只需要将pageInfo交给页面就可以
		PageInfo<Map<String, Object>> selectByOption = logService.selectByOption(map, pageNum, pageSize);
		List<Map<String, Object>> list = selectByOption.getList();
		return new ResultMap<List<Map<String, Object>>>(0, "", list, selectByOption.getTotal());
	}

	@RequestMapping(value = "/routeToLogList", method = RequestMethod.GET)
	public String routeToLogList() {
		return "layuiAdmin/admin/log/log";
	}

}
